/**
 * 电话
 * (1)电话号码由数字、"("、")"和"-"构成
 * (2)电话号码为3到8位
 * (3)如果电话号码中包含有区号，那么区号为三位或四位
 *  (4)区号用"("、")"或"-"和其他部分隔开
 * (5)移动电话号码为11或12位，如果为12位,那么第一位为0
 */
const telephone = {type: 'string', pattern: /(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^[0−9]3,4[0-9]{3,8}$)|(^0{0,1}1[0-9]{10}$)/, message: '请输入正确的联系方式', trigger: 'blur'}
const telephoneRule = /(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^[0−9]3,4[0-9]{3,8}$)|(^0{0,1}1[0-9]{10}$)/
/**
 * 邮箱
 */
const eMail = {type: 'string', pattern: /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/, message: '请输入正确的邮箱', trigger: 'blur'}
const eMailRule = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/

const idCard = {type: 'string', pattern: /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|[x,X])$/, message: '请输入正确的身份证号码', trigger: 'blur'}
const idCardRule = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|[x,X])$/
/**
 * 字符串最长长度校验
 * @param {len} len  长度
 */
const stringMax = function(len){
    var temp = {
        type: 'string',
        max: len,
        message: '最多输入' + len + '个字符',
        trigger: 'blur'
    }
    return temp
}
/**
 * 字符串最少长度校验
 * @param {len} len  长度
 */
const stringMin = function(len){
    var temp = {
        type: 'string',
        min: len,
        message: '最少输入' + len + '个字符',
        trigger: 'blur'
    }
    return temp
}
/**
 * 字符串固定长度
 * @param {len} len  长度
 */
const stringLen = function(len){
    var temp = {
        type: 'string',
        len: len,
        message: '只允许输入' + len + '个字符',
        trigger: 'blur'
    }
    return temp
}
export default {
    telephone: telephone,
    telephoneRule: telephoneRule,
    stringMax: stringMax,
    stringMin: stringMin,
    stringLen: stringLen,
    eMail: eMail,
    eMailRule: eMailRule,
    idCard: idCard,
    idCardRule: idCardRule
}
